package com.reportgenerate.configuration;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @program: reportgenerate
 * @Description: Swagger2配置类
 * @author: Mr.Cheng
 * @Email: ccelephant_518@126.com
 * @date: 2023/8/1 21:20
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
    * @Description: 市场报告服务
    * @Param: []
    * @return: springfox.documentation.spring.web.plugins.Docket
    * @Author: Mr.Cheng
    * @Email: ccelephant_518@126.com
    * @Date: 2023/8/1 21:31
    */
    @Bean
    public Docket describeMarketReportApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("市场报告服务")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.reportgenerate.marketreport.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(new ApiInfoBuilder()
                        .title("市场报告服务")
                        .description("市场报告服务")
                        .version("1.0")
                        .build())
                .enable(true);
    }

    /**
    * @Description: 创建该API的基本信息（这些基本信息会展现在文档页面中）
    *               访问地址：http://ip:port/swagger-ui.html
    * @Param: [title, version]
    * @return: springfox.documentation.service.ApiInfo
    * @Author: Mr.Cheng
    * @Email: ccelephant_518@126.com
    * @Date: 2023/8/1 21:38
    */
    private ApiInfo apiInfo(String title, String version) {
        return new ApiInfoBuilder()
                .title(title)
                .description("市场报告服务")
                .version(version)
                .build();
    }
}
